package com.ruoyi.find.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.find.domain.FurnitureRental;
import com.ruoyi.find.service.IFurnitureRentalService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 家具租赁综合Controller
 * 
 * @author yang
 * @date 2025-10-08
 */
@RestController
@RequestMapping("/rental")
public class FurnitureRentalController extends BaseController
{
    @Autowired
    private IFurnitureRentalService furnitureRentalService;

    /**
     * 查询家具租赁综合列表
     */
    @RequiresPermissions("find:rental:list")
    @GetMapping("/list")
    public TableDataInfo list(FurnitureRental furnitureRental)
    {
        startPage();
        List<FurnitureRental> list = furnitureRentalService.selectFurnitureRentalList(furnitureRental);
        return getDataTable(list);
    }

    /**
     * 导出家具租赁综合列表
     */
    @RequiresPermissions("find:rental:export")
    @Log(title = "家具租赁综合", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FurnitureRental furnitureRental)
    {
        List<FurnitureRental> list = furnitureRentalService.selectFurnitureRentalList(furnitureRental);
        ExcelUtil<FurnitureRental> util = new ExcelUtil<FurnitureRental>(FurnitureRental.class);
        util.exportExcel(response, list, "家具租赁综合数据");
    }

    /**
     * 获取家具租赁综合详细信息
     */
    @RequiresPermissions("find:rental:query")
    @GetMapping(value = "/{furnitureId}")
    public AjaxResult getInfo(@PathVariable("furnitureId") Long furnitureId)
    {
        return success(furnitureRentalService.selectFurnitureRentalByFurnitureId(furnitureId));
    }

    /**
     * 新增家具租赁综合
     */
    @RequiresPermissions("find:rental:add")
    @Log(title = "家具租赁综合", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FurnitureRental furnitureRental)
    {
        return toAjax(furnitureRentalService.insertFurnitureRental(furnitureRental));
    }

    /**
     * 修改家具租赁综合
     */
    @RequiresPermissions("find:rental:edit")
    @Log(title = "家具租赁综合", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FurnitureRental furnitureRental)
    {
        return toAjax(furnitureRentalService.updateFurnitureRental(furnitureRental));
    }

    /**
     * 删除家具租赁综合
     */
    @RequiresPermissions("find:rental:remove")
    @Log(title = "家具租赁综合", businessType = BusinessType.DELETE)
	@DeleteMapping("/{furnitureIds}")
    public AjaxResult remove(@PathVariable Long[] furnitureIds)
    {
        return toAjax(furnitureRentalService.deleteFurnitureRentalByFurnitureIds(furnitureIds));
    }
}
